package com.hdaccp.shuiguoD.controller;

import com.hdaccp.shuiguoD.dao.XiaoshoulsDao;
import com.hdaccp.shuiguoD.entity.Shangpin;
import com.hdaccp.shuiguoD.entity.Xiaoshou;
import com.hdaccp.shuiguoD.entity.Xiaoshouls;
import com.hdaccp.shuiguoD.service.XiaoshoulsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/xiaoshouls")
@Scope("prototype")
public class XiaoshoulsController {

    @Autowired
    private XiaoshoulsService xiaoshoulsService;
    @Autowired
    private XiaoshoulsDao xiaoshoulsDao;


    @RequestMapping("/addhuo")
    @ResponseBody
    public int addhuo(Xiaoshouls xiaoshouls){


        return xiaoshoulsService.addhuo(xiaoshouls);
    }

    @RequestMapping("/updata")
    @ResponseBody
    public int updata(Shangpin shangpin){
        return xiaoshoulsService.update(shangpin);
    }
    @RequestMapping("/del")
    @ResponseBody
    public int del(Shangpin shangpin){
        return xiaoshoulsDao.del();
    }

    @RequestMapping("/queryAll")
    @ResponseBody
    public List<Xiaoshouls> query(HttpServletRequest request){
        List<Xiaoshouls> list = xiaoshoulsService.queryAll();
        return list;
    }
}
